<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('nickname');
            $table->string('avatar')->nullable();
            $table->string('phone')->nullable();
            $table->string('password')->nullable();
            $table->string('password_salt')->nullable();
            $table->string('qyh_userid')->nullable();
            $table->unsignedTinyInteger('synced_with_qyh')->default(0)->comment("标识该条记录是否与企业微信通讯录保持一致0：否1：是");
            $table->unsignedTinyInteger('role')->default(0)->comment("0学生1教师2其他");
            $table->unsignedInteger("total_storage")->default(0)->comment("总容量，单位为KB，最大值即为4TB左右");
            $table->unsignedInteger("used_storage")->default(0)->comment("已使用容量，单位为KB，最大值即为4TB左右");
            $table->unsignedTinyInteger('status')->default(0)->cooment("0已停用1已启用");
            $table->string('api_token')->nullable();
            $table->dateTime('api_token_expire_at')->nullable();
            $table->timestamps();

            $table->unique('phone');
            $table->unique('qyh_userid');
            $table->index('api_token');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
